#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int T, n, m, len, lim;
int d[123456], v[123456], a[123456], tmpp;
double p[123456];
struct zone{
    double st, en;
    bool operator< (const zone b)const{
        return st<b.st;
    }
}z[123456];
int znt, snt, ans;
zone stk[123456];
bool doubleeq (double x, double y){
    return fabs(x-y) < 0.00001;
}
bool doubleleeq (double x,double y){
    return x<y || doubleeq(x, y);
}
bool doublegreq (double x,double y){
    return x>y || doubleeq(x, y);
}
void mian(){
    scanf("%d%d%d%d", &n, &m, &len, &lim);
    znt = 0;
    for(int i=1;i<=n;i++){
        scanf("%d%d%d", &d[i], &v[i], &a[i]);
        if(v[i]>lim&&a[i]>=0){//overspeed forever
            znt++;
            z[znt] = {double(d[i])-0.00015, double(len)+0.0001};
        }else if(v[i]>lim&&a[i]<0){//overspeed a while
            znt++;
            double overspeed_s = double(lim*lim-v[i]*v[i])/a[i]/2;
            z[znt] = {double(d[i])-0.00015, d[i]+overspeed_s-0.0001};
        }else if(v[i]<=lim&&a[i]>0){//first not overspeed but then do forever
            double noverspeed_s = double(lim*lim-v[i]*v[i])/a[i]/2;
            if(doubleleeq(d[i]+noverspeed_s, len)){
                znt++;
                z[znt] = {d[i]+noverspeed_s+0.00015, double(len)+0.0001};
            }
        }else if(v[i]<=lim&&a[i]<=0){//good people
            //
        }
    }
    for(int i=1;i<=m;i++){
        scanf("%d", &tmpp);
        p[i] = double(tmpp);
    }
    for(int i=1;i<=znt;i++){//judge avalible
        double st = z[i].st, en = z[i].en;
        int bound1 = upper_bound(p+1, p+m+1, st)-p-1;
        int bound2 = upper_bound(p+1, p+m+1, en)-p-1;
        if(bound1==bound2){ // delete zone
            z[i].st = z[znt].st;
            z[i].en = z[znt].en;
            znt--;
            i--;
        }
    }
    sort(z+1, z+znt+1);
    printf("%d ", znt);
    // printf("\n");
    // for(int i=1;i<=znt;i++){
    //     printf("%.0lf->%.0lf\n", z[i].st, z[i].en);
    // }
    snt++;
    stk[snt] = z[1];
    // printf("\nstktop: %.0lf->%.0lf | snt=%d\n", stk[snt].st, stk[snt].en, snt);
    for(int i=2;i<=znt;i++){
        double st1 = stk[snt].st, en1 = stk[snt].en;
        double st2 = z[i].st, en2 = z[i].en;
        if(st2<en1){
            int bound1 = upper_bound(p+1, p+m+1, st2)-p-1;
            int bound2 = upper_bound(p+1, p+m+1, en1)-p-1;
            if(bound1<bound2){
                stk[snt] = {st1, min(en1, en2)};
            }else{
                snt++;
                stk[snt] = z[i];
            }
        }else{
            snt++;
            stk[snt] = z[i];
        }
        // printf("stktop: %.0lf->%.0lf | snt=%d\n", stk[snt].st, stk[snt].en, snt);
    }
    ans = 0;
    for(;snt;snt--){
        ans += 1;
    }
    if(znt==0) ans = 0;
    printf("%d\n", m-ans);
}
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &T);
    while(T--){
        mian();
    }
    return 0;
}
//g++ x.cpp -o x -O2 -std=c++14 -Wall -Wshadow